<template>
  <!-- 输入框 -->
  <header class="header">
    <h1>小黑记事本</h1>
    <input
      placeholder="请输入任务"
      class="new-todo"
      v-model="info"
      @keyup.enter="add"
    />
    <button class="add" @click="add">添加任务</button>
  </header>
</template>

<script>
export default {
  data() {
    return {
      info: "",
    };
  },
  methods: {
    add() {
      if (this.info === "") {
        return alert("请输入内容");
      } else {
        this.$emit("add", this.info);
        this.info = "";
      }
    },
  },
};
</script>

<style>
</style>